﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace eschoolBO
{
    public class timetable
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _time_table_id = -99;
        private long _teacher_id = -99;
        private long _class_id = -99;
        private long _subject_id = -99;
        private string _dayname = "";
        private string _starttime = "";
        private string _endtime = "";
        private bool _isdeleted = false;
        public long time_table_id
        {
            get
            {
                return _time_table_id;
            }
            set
            {
                _time_table_id = value;
            }
        }
        public long teacher_id
        {
            get
            {
                return _teacher_id;
            }
            set
            {
                _teacher_id = value;
            }
        }
        public long class_id
        {
            get
            {
                return _class_id;
            }
            set
            {
                _class_id = value;
            }
        }
        public long subject_id
        {
            get
            {
                return _subject_id;
            }
            set
            {
                _subject_id = value;
            }
        }
        public string dayname
        {
            get
            {
                return _dayname;
            }
            set
            {
                _dayname = value;
            }
        }
        public string starttime
        {
            get
            {
                return _starttime;
            }
            set
            {
                _starttime = value;
            }
        }
        public string endtime
        {
            get
            {
                return _endtime;
            }
            set
            {
                _endtime = value;
            }
        }
        public bool isdeleted
        {
            get
            {
                return _isdeleted;
            }
            set
            {
                _isdeleted = value;
            }
        }
        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@time_table_id", time_table_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@teacher_id", teacher_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@class_id", class_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@dayname", dayname, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@subject_id", subject_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@starttime", starttime, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@endtime", endtime, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3,dbparam4,dbparam5,dbparam6 ,dbparam7};
                return DAC.Save("timetable_save", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long time_table_id, long teacher_id,long subject_id,long class_id,string starttime,string endtime,string dayname,bool isdeleted, string paraandor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@time_table_id", time_table_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@teacher_id", teacher_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@class_id", class_id, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@dayname", dayname, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@subject_id", subject_id, DbType.Int64, ParameterDirection.Input); 
                DbParameter dbparam5 = DAC.Parameter("@starttime", starttime, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@endtime", endtime, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam8 = DAC.Parameter("@paraandor", paraandor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4,dbparam5,dbparam6,dbparam7,dbparam8};
                DataTable dt1 = DAC.Select("timetable_get", dbparamcall);
                return dt1;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }
    }
}
